<%-- 
    Document   : sfxmwh
    Created on : 2016-7-22, 13:58:23
    Author     : cxhd
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%@include file="../../link.jsp" %>
<!--        <link href="../../css/bootstrap-paper.css" rel="stylesheet" type="text/css"/>
        <script type="text/javascript" src="${base}/js/bootstrap.min.js"></script>-->
        <title>JSP Page</title>
    </head>
     <style>
        tr>td{
            padding: 4px 4px 4px 4px;
            /*padding-bottom: 4px;*/
        }
        th{
            padding:4px 4px 4px 4px;
            font:bold;
            text-align:center;
        }
        .error{font-size: 1px; color: red}
    </style>
    <body style="font-family: 微软雅黑;margin-top: 10px;" ng-app="sfxmwh" ng-controller="mainTab">
          <div class="col-lg-12">
            <div class="panel panel-default" style="overflow: hidden">

                <div class="panel-heading"><span style="float: left">收费项目列表</span>
                    <div>
                        <input ng-model="searchContent"  placeholder="名字/ID" style="width:320px; float: left;margin-left: 20px" class="form-control input-sm" />
                        <button ng-click="getCharginitem()" style="float: left" class="btn btn-success btn-sm"><span class="fa fa-search"></span>&nbsp;&nbsp;搜索</button>

                        <button ng-click="OpenSaveModal()" style="margin-left: 30px;float: left" class="btn btn-info btn-sm"><span class="fa fa-send"></span>&nbsp;&nbsp;添加</button></div>
                       
                    <div style="clear: both"></div>
                </div>

                <table class="table table-striped table-bordered  table-hover ">
                    <thead>
                       <tr>
                                <th class="table-id">序号</th>
                                <th class="table-id">项目编号</th>
                                <th class="table-title">收费项目名</th>
                                <th class="table-type">价格</th>
                                 <th class="table-author">添加时间</th>
                                 <th class="table-set">操作</th>
                            </tr>
                    </thead>
                    <tbody>
                             <tr  ng-repeat="citem in citems" >
                                <td>{{$index}}</td>
                                <td>{{citem.ITEMID}}</td>
                                <td>{{citem.ITEMNAME}}</td>
                                <td style="text-align: center">{{citem.PRICE}}</td>
                                <td style="text-align: center">{{citem.DATA1}}</td>
                                <td>
                                    <button ng-click="OpenUpdateModal(citem)" class="btn btn-success btn-xs"><span class="fa fa-edit"></span>修改</button>
                                    <button ng-click="deleteCharginitem(citem)" class="btn btn-danger btn-xs"><span class="fa fa-bolt"></span>删除</button>
                                </td>
                            </tr>
                    </tbody>
                </table>  
                  
                <footer class="panel-heading">
                    <div class="row">
                        <div style="text-align: center" >                
                            <pagination ng-change="pageChanged()" previous-text="上一页" next-text="下一页" first-text="第一页" last-text="最后一页" ng-model="data.currentPage" items-per-page="data.pageSize" total-items="data.bigTotalItems" ng-model="data.bigCurrentPage" max-size="data.maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages"></pagination>

                        </div>
                    </div>
                </footer>

            </div>

        </div>

        
            <div class="modal fade mode-x" role="dialog" aria-labelledby="gridSystemModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-click="CloseModel()"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="gridSystemModalLabel">{{title}}收费项目</h4>
                    </div>
                    <div class="modal-body">
                        <form  name="cfrom" id="profile">
                            <table style="width: 100%">                             
                                <tr><td>收费项目名:<input type="text" name="itemname" ng-model="tmpcitem.ITEMNAME" style="width: 100px" ng-minlength=1 ng-maxlength=20 required><label style="color:red;">&lowast;</label>
                                        <div class="error" ng-show="cfrom.itemname.$dirty && cfrom.itemname.$invalid">
                         <small class="error" ng-show="cfrom.itemname.$error.required">科室名不能为空。</small>
                         <small class="error" ng-show="cfrom.itemname.$error.minlength">科室名长度不能小于1</small>
                         <small class="error" ng-show="cfrom.itemname.$error.maxlength">科室名长度不能大于10</small> 
                         
                         </div>
                                    </td>
                                    
                            <td>收费：
                                <input type="text" ng-model="tmpcitem.PRICE" style="width: 100px"/>
                            </td> 

                        </tr>          

                    </table>
                            </table>
                        </form>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="CloseModel()">关闭</button>
                        <button  ng-click="savePro()"  type="button" ng-disabled="cfrom.$invalid" class="btn btn-primary"><span class="fa fa-save"></span>&nbsp;&nbsp;保存</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
        
        
    </body>
    <script>
         angular.module("sfxmwh", ['baseModule', 'ui.bootstrap'])
            .controller("mainTab", function ($scope,base) {
 
                 $scope.tmpcitem={PK:""};
                $scope.searchContent="";
                   
                $scope.data = {currentPage: 1};
                $scope.setPage = function (pageNo) {
                    $scope.data.currentPage = pageNo;
                };

                $scope.pageChanged = function () {
                   $scope.getCharginitem();
                };

                $scope.data.maxSize = 10;
                $scope.data.bigTotalItems = 20;
                $scope.data.bigCurrentPage = 1;
                $scope.data.pageSize = 10;

                $scope.getCharginitem=function(){//显示
               base.post("citem/getLisCharginitem",{pageSize: $scope.data.pageSize, currentPage: $scope.data.currentPage,searchContent:$scope.searchContent}).get(function(data){ //参数 分页参数
//                    console.log(data);
                    if(data){
                       $scope.citems=data.list;
                       $scope.data.bigTotalItems = data.totalRow;
//                       $scope.$apply();
                    }
                })
            }
            $scope.getCharginitem();
               $scope.deleteCharginitem=function(tmp){
                
                  var gnl=confirm("你真的确定要删除吗?"); //友好提示
                if (gnl==true){ 
                base.post("citem/deleteLisCharginitem",{PK:tmp.PK}).get(function(data){
                    if(data=='true'){
                        alert("删除成功",1000);
                        $scope.getCharginitem();
                        $scope.$apply();
                    }
                })
            }else{
                return;
            }
            }
                
                 $scope.OpenSaveModal = function () {
                     $scope.title="新增";
                    $(".mode-x").modal('show');
                }
                $scope.OpenUpdateModal=function(tmp){
                      $scope.title="修改";
                     $scope.tmpcitem=tmp;
                    $(".mode-x").modal('show');   
                }
               $scope.CloseModel=function(){//关闭窗口的同时清空窗口数据
                   $scope.tmpcitem={PK:""};
                    $scope.getCharginitem();
               }
               
               $scope.savePro=function(){//必须要验证 显示序号 和扩展类型为数值
//                   if($scope.SAMPLETYPE==""||$scope.SAMPLEDESCRIBE==""){//验证
//                       alert("代码或样本类型不能为空",1000);
//                       return;
//                   }
                 base.post("citem/getLisCharginitemRep",{PK:$scope.tmpcitem.PK,ITEMNAME:$scope.tmpcitem.ITEMNAME}).get(function(data){
               
                     if(data=='true'){
                         alert("项目名称在数据库中已存在",1000);
                         return;
                     } 
                     
                 if($scope.tmpcitem.PK!=""){//修改
                     base.post("citem/updateLisCharginitem",$scope.tmpcitem).get(function(data){
                    if(data=='true'){
                       $scope.getCharginitem();
                        alert("修改成功！");
                    }
                })  
                 }else{//保存 
                    base.post("citem/saveLisCharginitem",$scope.tmpcitem).get(function(data){
                    if(data=='true'){
                       $scope.getCharginitem();
                        alert("新增成功！");
                    }
                })
                 }
                 
                  $(".mode-x").modal('hide');
                 $scope.CloseModel();
              
                
                 })  
               }
            })
    </script>
 <!--    <body ng-app="sfxmwh" ng-controller="sz">
   <style>
        tr>th{ padding: 1px}
    </style>
    <div>
   <div class="col w-lg bg-light dk b-r bg-auto" id="aside" style="background-color: #ffffff;width: 50%">
                <div class="wrapper bg b-b" style="height: 48px;">
                    <button class="btn btn-sm btn-success pull-right" ui-toggle-class="timeline-center" target=".timeline">Center</button>
                    <h4 class="m-n font-thin">仪器浏览</h4>
                </div>
                <div class="wrapper" >
                    <form class="ng-pristine ng-valid">
                        <table  class="table table-striped table-bordered  table-hover" style="width:100%"  >
                            <tr>
                                <th class="table-id">序号</th>
                                <th class="table-title">收费项目名</th>
                                <th class="table-type">价格</th>
                                 <th class="table-author">添加时间</th>
                                  
                            </tr>
                            <tr  ng-repeat="citem in citems" ng-click="getCharginitemInfo(citem)">
                                <td>{{$index}}</td>
                                <td>{{citem.ITEMNAME}}</td>
                                <td>{{citem.PRICE}}</td>
                                <td>{{citem.DATA1}}</td>
                                
                            </tr>
                        </table>
                    </form>
                    
                    <footer class="panel-heading">
                    <div class="row">
                        <div style="text-align: center" >                
                            <pagination ng-change="pageChanged()" previous-text="上一页" next-text="下一页" first-text="第一页" last-text="最后一页" ng-model="data.currentPage" items-per-page="data.pageSize" total-items="data.bigTotalItems" ng-model="data.bigCurrentPage" max-size="data.maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages"></pagination>

                        </div>
                    </div>
                </footer>
                    
                </div>
            </div>
    <div style="position: fixed;left:50%;top: 0px;bottom: 0px; width:50%;margin-bottom: 20px;">
        <div>
            <button class="btn m-b-xs btn-sm btn-success btn-addon" ng-click="saveCharginitem()"><i class="fa fa-save"></i>保存</button>
            <button class="btn m-b-xs btn-sm btn-danger btn-addon" ng-click="deleteCharginitem()"><i class="fa fa-plus"></i>删除</button>
            <button class="btn m-b-xs btn-sm btn-primary btn-addon" ng-click="cancelEvent()"><i class="fa fa-cab"></i>取消</button>
            <button class="btn m-b-xs btn-sm btn-primary btn-addon" ng-click="newCharginitem()"><i class="fa fa-save"></i>添加仪器</button>
            <button class="btn m-b-xs btn-sm btn-info btn-addon"><i class="fa fa-print"></i>打印</button>
            <button class="btn m-b-xs btn-sm btn-info btn-addon"><i class="fa fa-close"></i>退出</button>
        </div>
            <ul class="nav nav-tabs" role="tablist">
    <li role="presentation" class="active"><a href="/demo/bootstrap3-plugin-tab.htm#home" aria-controls="home" role="tab" data-toggle="tab">基础信息</a></li>
    
  </ul>

  <div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="home">
       <table class="table table-striped table-bordered  table-hover" style="width:100%" >
            <tr><td>收费项目名:<input type="text" ng-model="tmpcitem.ITEMNAME" style="width: 100px"/></td>
                <td>收费：
                    <input type="text" ng-model="tmpcitem.PRICE" style="width: 100px"/>
                </td> 
                
            </tr>          

        </table>
  
</div>
     
  </div>
        </div>
    </div>
</body>

    <script>
        angular.module("sfxmwh",['baseModule', 'ui.bootstrap'])
               .controller("sz", function ($scope,$http) {
                  
                  
                   var so = $scope;
                $scope.data = {currentPage: 1};
                so.setPage = function (pageNo) {
                    $scope.data.currentPage = pageNo;
                };
                so.pageChanged = function () {
                    $scope.getCharginitem();
                };
                so.data.maxSize = 10;
                so.data.bigTotalItems = 20;
                so.data.bigCurrentPage = 1;
                so.data.pageSize = 10;
                
                   $scope.tmpcitem={PK:""};
              $scope.getCharginitem=function(){
                $.post("citem/getLisCharginitem",{pageSize: so.data.pageSize, currentPage: so.data.currentPage},function(data){ //参数 分页参数
                    console.log(data);
                    if(data){
                       $scope.citems=data.list;
                       so.data.bigTotalItems = data.totalRow;
                       $scope.$apply();
                       
                    }
                })
            }
            $scope.getCharginitem();
            $scope.getCharginitemInfo=function(info){
                $scope.tmpcitem=info;

            } 
            $scope.deleteCharginitem=function(){
                if($scope.tmpcitem.PK==""){
                    alert("请选择要删除的项目");
                    return;
                }
                  var gnl=confirm("你真的确定要删除吗?"); //友好提示
                if (gnl==true){ 
                $.post("citem/deleteLisCharginitem",{PK:$scope.tmpcitem.PK},function(data){
                    if(data=='true'){
                        alert("删除成功",1000);
                        $scope.getCharginitem();
                        $scope.$apply();
                    }
                })
            }else{
                return;
            }
            }
            $scope.cancelEvent=function(){
         $scope.newCharginitem();
          
            }
            $scope.newCharginitem=function(){//新项目
                $scope.tmpcitem={PK:""};
            }
            
            $scope.saveCharginitem=function(){//保存项目或保存修改
                
                if( $scope.tmpcitem.PK==""){ //新增 
                $.post("citem/saveLisCharginitem",$scope.tmpcitem,function(data){
                    if(data=='true'){
                       $scope.getCharginitem();
                        alert("新增成功！",1000);
                    }
                })
                  }else{// 修改
                 $.post("citem/updateLisCharginitem",$scope.tmpcitem,function(data){
                    if(data=='true'){
                        $scope.getCharginitem();
                        alert("修改成功！",1000);
                    }
                })  
                  }
            }
           
        })

    </script>-->
</html>

